import psycopg2
from django.test import TestCase

conn = psycopg2.connect(database="hucl_test", user="postgres", password="seiot111", host="192.168.2.235", port="5432")

# Create your tests here.
with open(r'C:\Users\Administrator\Desktop\new 1.txt', encoding='UTF-8') as f:
    for line in f.readlines():
        item = eval(line)
        for i in item['root']:
            print(item['root'].index(i), i)
            item_id = item['root'].index(i) + 1
            cur = conn.cursor()
            sql_str = f"INSERT INTO config_mfacturer_oid (id,mfacturer_oid,dev_type,mfacturer,unit_type) VALUES ({item_id},'{i['strdevoid']}','{i['strdevtype']}','{i['strvendor']}','{i['strdevmodel']}')"
            cur.execute(sql_str)
            conn.commit()
        conn.close()
